package leetcode_81_100;

import org.junit.Test;
import utils.ListNode;
import utils.TreeNode;

import java.lang.reflect.InvocationTargetException;

public class Tset5 {
    @Test
    //搜索旋转排序数组 II
    public void test81(){
        int[]a={1,1};
        System.out.println(new search_81().search(a,0));
    }

    @Test
    //删除排序链表中的重复元素
    public void test83(){
        ListNode listNode1=new ListNode(1);
        ListNode listNode2=new ListNode(3);
        ListNode listNode3=new ListNode(3);
        ListNode listNode4=new ListNode(3);
        ListNode listNode5=new ListNode(4);
        ListNode listNode6=new ListNode(4);
        ListNode listNode7=new ListNode(5);
        listNode1.next=listNode2;
        listNode2.next=listNode3;
        listNode3.next=listNode4;
        listNode4.next=listNode5;
        listNode5.next=listNode6;
        listNode6.next=listNode7;

        new deleteDuplicates_83().deleteDuplicates(listNode1);
    }

    @Test
    //删除排序链表中的重复元素 II
    public void test82(){
        ListNode listNode1=new ListNode(1);
        ListNode listNode2=new ListNode(3);
        ListNode listNode3=new ListNode(3);
        ListNode listNode4=new ListNode(3);
        ListNode listNode5=new ListNode(4);
        ListNode listNode6=new ListNode(4);
        ListNode listNode7=new ListNode(5);
        listNode1.next=listNode2;
        listNode2.next=listNode3;
        listNode3.next=listNode4;
        listNode4.next=listNode5;
        listNode5.next=listNode6;
        listNode6.next=listNode7;

        new deleteDuplicates_82().deleteDuplicates(listNode1);
    }

    @Test
    //柱状图中最大的矩形
    public void test84(){
        int[]a={2,1,5,5,5,6,2,3};
        System.out.println(new largestRectangleArea_84().largestRectangleArea2(a));
    }

    @Test
    //最大矩形
    public void test85(){
//        char[][]a = {{'1','0','1','0','0'},
//                {'1','0','1','1','1'},
//                {'1','1','1','1','1'},
//                {'1','0','0','1','0'}};
//        char[][]a = {{'0','1'}};
        char[][]a = {{'1','0','0','0','1'},
                {'1','1','0','1','1'},
                {'1','1','1','1','1'}};
        System.out.println(new maximalRectangle_85().maximalRectangle2(a));
    }

    @Test
    //分隔链表
    public void test86(){
        ListNode listNode1=new ListNode(1);
        ListNode listNode2=new ListNode(4);
        ListNode listNode3=new ListNode(3);
        ListNode listNode4=new ListNode(2);
        ListNode listNode5=new ListNode(5);
        ListNode listNode6=new ListNode(2);
        ListNode listNode7=new ListNode(5);
        listNode1.next=listNode2;
        listNode2.next=listNode3;
        listNode3.next=listNode4;
        listNode4.next=listNode5;
        listNode5.next=listNode6;
        //listNode6.next=listNode7;

        new partition_86().partition(listNode1,3);
    }

    @Test
    //扰乱字符串
    public void test87(){
        String s1 = "leetcode", s2 = "etledeco";
        System.out.println(new isScramble_87().isScramble(s1,s2));
    }

    @Test
    //合并两个有序数组
    public void test88(){
        int []nums1 = {2,0}, nums2 = {1};
        int m = 1, n = 1;
        new merge_88().merge2(nums1,m,nums2,n);
    }

    @Test
    // 格雷编码
    public void test89(){
        System.out.println(new grayCode_89().grayCode(3));
    }

    @Test
    // 子集 II
    public void test90(){
        int []nums = {4,4,1,4};
        System.out.println(new subsetsWithDup_90().subsetsWithDup(nums));
    }

    @Test
    // 解码方法
    public void test91(){
        String s = "230";
        System.out.println(new numDecodings_91().numDecodings(s));
    }

    @Test
    // 反转链表 II
    public void test92(){
        ListNode listNode1=new ListNode(1);
        ListNode listNode2=new ListNode(2);
        ListNode listNode3=new ListNode(3);
        ListNode listNode4=new ListNode(4);
        ListNode listNode5=new ListNode(5);
        ListNode listNode6=new ListNode(6);
        ListNode listNode7=new ListNode(7);
        listNode1.next=listNode2;
        listNode2.next=listNode3;
        listNode3.next=listNode4;
        listNode4.next=listNode5;
//        listNode5.next=listNode6;
//        listNode6.next=listNode7;

        new reverseBetween_92().reverseBetween2(listNode1,2,4);
    }

    @Test
    // 解码方法
    public void test93(){
        String s = "101023";
        System.out.println(new restoreIpAddresses_93().restoreIpAddresses(s));
    }


    @Test
    //二叉树的中序遍历
    public void test94(){
        TreeNode treeNode1=new TreeNode(1);
        TreeNode treeNode2=new TreeNode(2);
        TreeNode treeNode3=new TreeNode(3);
        TreeNode treeNode4=new TreeNode(4);
        TreeNode treeNode5=new TreeNode(5);

//        //1,3,4
//        treeNode1.right=treeNode3;
//        treeNode3.left=treeNode4;

        //1,2,4,5,3
        treeNode1.left=treeNode2;
        treeNode1.right=treeNode3;
        treeNode2.left=treeNode4;
        treeNode2.right=treeNode5;
        new inorderTraversal_94().inorderTraversal2(treeNode1);
    }

    @Test
    //不同的二叉搜索树
    public void test96() {
        System.out.println(new numTrees_96().numTrees(2));
    }
    @Test
    //不同的二叉搜索树 II
    public void test95(){
        new generateTrees_95().generateTrees2(3);
    }

    @Test
    //交错字符串
    public void test97(){
        String s1 = "aabcc", s2 = "dbbca", s3 = "aadbbbaccc";
        System.out.println(new isInterleave_97().isInterleave(s1,s2,s3));
    }


    @Test
    // 验证二叉搜索树
    public void test98(){
        TreeNode treeNode1=new TreeNode(120);
        TreeNode treeNode2=new TreeNode(70);
        TreeNode treeNode3=new TreeNode(140);
        TreeNode treeNode4=new TreeNode(50);
        TreeNode treeNode5=new TreeNode(100);
        TreeNode treeNode6=new TreeNode(130);
        TreeNode treeNode7=new TreeNode(160);


//        treeNode1.left=treeNode2;
//        treeNode1.right=treeNode3;
////        treeNode3.left=treeNode4;
////        treeNode3.right=treeNode5;

//        treeNode1.left = treeNode2;
//        treeNode1.right = treeNode3;


        treeNode1.left = treeNode2;
        treeNode1.right = treeNode3;
        treeNode2.left = treeNode4;
        treeNode2.right = treeNode5;
        treeNode3.left = treeNode6;
        treeNode3.right = treeNode7;

        System.out.println(new isValidBST_98().isValidBST(treeNode1));
    }

    @Test
    //恢复二叉搜索树
    public void test99(){
        TreeNode treeNode1=new TreeNode(1);
        TreeNode treeNode2=new TreeNode(3);
        TreeNode treeNode3=new TreeNode(2);
        TreeNode treeNode4=new TreeNode(50);
        TreeNode treeNode5=new TreeNode(100);
        TreeNode treeNode6=new TreeNode(130);
        TreeNode treeNode7=new TreeNode(160);

        treeNode1.left=treeNode2;
        treeNode2.right=treeNode3;

        new recoverTree_99().recoverTree(treeNode1);
    }

    @Test
    //相同的树
    public void test100(){
        TreeNode treeNode1=new TreeNode(1);
        TreeNode treeNode2=new TreeNode(3);
        TreeNode treeNode3=new TreeNode(2);

        TreeNode treeNode4=new TreeNode(1);
        TreeNode treeNode5=new TreeNode(3);
        TreeNode treeNode6=new TreeNode(2);

        treeNode1.left=treeNode2;
        treeNode1.right=treeNode3;

        treeNode4.left=treeNode5;
        treeNode4.right=treeNode6;

        new isSameTree_100().isSameTree(treeNode1,treeNode4);
    }
}
